
/**
 房间运营状态
 *
*/

import { State } from "framework/FSM/AState";
 
import { priority } from "utils/constants/definetypes";
import { dangrous_style, structureTip_style, table_row_style, table_title_style, target_style } from "utils/constants/globalconstant";
import { TaskHelper } from "utils/task/TaskHelper";
import { VisualHelper } from "utils/visual/visual";

 
export class RoomVisualState<T extends IStateArg<Room >> extends State<T>
{
    
    public getActions(arg:T):Action[]
    {
        if(arg.entity.memory.warinfo)
        {
            const cache = arg.entity.getWorld().PollBlueplan(arg.entity.name);
            if(cache)
            {
                arg.entity.visual.import(cache.safe_matrix_drawing);
            }
        }
        const healp = Game.cpu.getHeapStatistics!();
        if(healp)
        {
            const keys  = Object.keys( healp);
            let leftpad= 35;
            for(let i=0;i<keys.length;i++)
            { 
                arg.entity.visual.text(keys[i],leftpad,i+2,table_row_style);
                arg.entity.visual.text(healp[keys[i] as keyof HeapStatistics].toString(),leftpad+10,i+2,table_row_style);
            }
            
        }
        /*
        {
            // 任务信息可视化
            const tasks = arg.entity.memory.Tasks;
            const tasktypes:TaskType[]= Object.keys(arg.entity.memory.Tasks) as any;//
            //['KeepCreep','boost','core','creep','factory','pc','react','room','spawn','team','terminal','tower'];
            let leftpad= 3;
            let radio = 0.8;
            for(let i=0;i<tasktypes.length;i++)
            { 
                if(tasks[tasktypes[i] ])
                {
                    arg.entity.visual.text(tasktypes[i],leftpad,(i+2)*radio,table_row_style);
                    arg.entity.visual.text(tasks[tasktypes[i] ].length.toString(),leftpad+4,(i+2)*radio,table_row_style);
                }
                
            }
        }
        {
            // 孵化信息可视化
        }
        {
            // lab信息可视化
            const labs  = arg.entity.getStructures('lab');
            for(const e of labs)
            {
                if(e.mineralType)
                {
                    arg.entity.visual.text(e.mineralType,e.pos.x,e.pos.y,structureTip_style);
                }
            }
        }
        {
            // 工厂信息可视化
            const tasks = arg.entity.getTaskByType('factory');
            const factory = arg.entity.getStructures('factory')[0];
            if(tasks[0]&& factory)
            {
                arg.entity.visual.text(tasks[0].data.arg.TopTask.target,factory.pos.x,factory.pos.y,structureTip_style);
            }
        }
        */
        // const inner = arg.entity.getEntitys("InnerMineEntity");
        // for(const e of inner)
        // {
        //     const path  = e.getPath();
        //     for(const p of path)
        //     {
        //         const room = Game.rooms[p.roomName];
        //         if(!room)
        //         {
        //             continue
        //         }
        //         room.visual.circle(p,target_style)
        //     }
        // }
        // const outer = arg.entity.getEntitys("OutMineEntity");
        // for(const e of outer)
        // {
        //     const path  = e.getPath();
        //     for(const p of path)
        //     {
        //         const room = Game.rooms[p.roomName];
        //         if(!room)
        //         {
        //             continue
        //         }
        //         room.visual.circle(p,target_style)
        //     }
        // }
        // 房间爬虫绑定
        // 返回的Action为一组可以立即执行的Action命令参数
        return [];
    }
    
}
